﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RR93Response", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR93Response))]
    public class RR93ResponseSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRR93Response clazz;
        
        public RR93ResponseSerializer(IRR93Response clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("pocIsikukood");
            if (clazz.PocIsikukood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocIsikukood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocIsikukood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocIsikuEnimi");
            if (clazz.PocIsikuEnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocIsikuEnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocIsikuEnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocIsikuPnimi");
            if (clazz.PocIsikuPnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocIsikuPnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocIsikuPnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("pocTeenusekood");
            if (clazz.PocTeenusekood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PocTeenusekood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : PocTeenusekood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("AVVeaTekst");
            if (clazz.AVVeaTekst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AVVeaTekst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : AVVeaTekst");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Vastuse_Tekst");
            if (clazz.VastuseTekst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.VastuseTekst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : VastuseTekst");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Veakood");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.Veakood))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("Veatekst");
            if (clazz.Veatekst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Veatekst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Veatekst");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="pocIsikukood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR93Response>pocIsikukood");
                }
                clazz.PocIsikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocIsikukood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR93Response>pocIsikukood", Reader.LocalName);
            }
            if (Reader.LocalName=="pocIsikuEnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR93Response>pocIsikuEnimi");
                }
                clazz.PocIsikuEnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocIsikuEnimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR93Response>pocIsikuEnimi", Reader.LocalName);
            }
            if (Reader.LocalName=="pocIsikuPnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR93Response>pocIsikuPnimi");
                }
                clazz.PocIsikuPnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocIsikuPnimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR93Response>pocIsikuPnimi", Reader.LocalName);
            }
            if (Reader.LocalName=="pocTeenusekood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR93Response>pocTeenusekood");
                }
                clazz.PocTeenusekood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("pocTeenusekood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR93Response>pocTeenusekood", Reader.LocalName);
            }
            if (Reader.LocalName=="AVVeaTekst") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR93Response>AVVeaTekst");
                }
                clazz.AVVeaTekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("AVVeaTekst")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR93Response>AVVeaTekst", Reader.LocalName);
            }
            if (Reader.LocalName=="Vastuse_Tekst") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR93Response>Vastuse_Tekst");
                }
                clazz.VastuseTekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Vastuse_Tekst")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR93Response>Vastuse_Tekst", Reader.LocalName);
            }
            if (Reader.LocalName=="Veakood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR93Response>Veakood");
                }
                clazz.Veakood = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("Veakood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR93Response>Veakood", Reader.LocalName);
            }
            if (Reader.LocalName=="Veatekst") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR93Response>Veatekst");
                }
                clazz.Veatekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Veatekst")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR93Response>Veatekst", Reader.LocalName);
            }
        }
    }
}
